<table cellpadding="1" cellspacing="5" style="border-spacing:15px; border-collapse:separate;">
    <tr><td width="29"></td>
      <td>&nbsp;</td>
      <td></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td></td>
      <td align="right">主机名称：
        
      </td>
      <td><input class="Ipt" id="title" type="text" value="" name="title" onBlur="this.className='Ipt'" onFocus="this.className='IptOnF'"></td>
      <td align="right">主机类型：</td>
      <td>
      <input type="radio" name="types" id="radio1" value="read_host" checked="checked" />文件
      <input type="radio" name="types" id="radio2" value="pic_host" />图片
      <input type="radio" name="types" id="radio3" value="html_host" />html
      </td>
    </tr>                                <tr>
      <td></td>
      <td align="right">主机域名：      </td>
      <td><input class="Ipt" id="host_name" type="text" value="" name="host_name" onBlur="this.className='Ipt'" onFocus="this.className='IptOnF'"></td>
      <td align="right">存储方式：</td>
      <td><input name="storage_type" type="radio" id="ftp" value="ftp" />
        ftp
        <input name="storage_type" type="radio" id="local" value="local" checked="checked" />
        本地
      <input type="radio" name="storage_type" id="network" value="network" />
      网络</td>
    </tr>                                                                <tr>
      <td></td>
      <td align="right">外网ip：      </td>
      <td><input class="Ipt" id="web_ip" type="text" value="" name="web_ip" onBlur="this.className='Ipt'" onFocus="this.className='IptOnF'"></td>
      <td align="right">本地存储路径：</td>
      <td><input name="local_path" type="text" class="Ipt" id="local_path" onfocus="this.className='IptOnF'" onblur="this.className='Ipt'" value="" maxlength="50" /></td>
    </tr>                                <tr>
      <td></td>
      <td align="right">局域网ip：      </td>
      <td><input class="Ipt" id="local_ip" type="text" value="" name="local_ip" onBlur="this.className='Ipt'" onFocus="this.className='IptOnF'"></td>
      <td align="right">ftp用户名：</td>
      <td><input name="ftp_user" type="text" class="Ipt" id="ftp_user" onfocus="this.className='IptOnF'" onblur="this.className='Ipt'" value="" maxlength="50" /></td>
    </tr>                                <tr>
      <td></td>
      <td align="right">是否激活：      </td>
      <td><input name="is_use" type="radio" id="is_use1" value="1" checked="checked" />
        激活
        <input type="radio" name="is_use" id="is_use0" value="0" />
        不激活</td>
      <td align="right">ftp密码：</td>
      <td><input name="ftp_passwd" type="password" class="Ipt" id="ftp_passwd" onfocus="this.className='IptOnF'" onblur="this.className='Ipt'" value="" maxlength="50" /></td>
    </tr>
    <tr>
      <td></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td align="right">ftp端口：</td>
      <td><input name="ftp_port" type="text" class="Ipt" id="ftp_port" onfocus="this.className='IptOnF'" onblur="this.className='Ipt'" value="" maxlength="6" /></td>
    </tr>
    <tr>
      <td></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td align="right">网络存储URL：</td>
      <td><input name="network_url" type="password" class="Ipt" id="network_url" onfocus="this.className='IptOnF'" onblur="this.className='Ipt'" value="" maxlength="250" /></td>
    </tr>
    <tr>
      <td></td>
      <td>&nbsp;</td>
      <td><input class="Btn BtnNml" onMouseOver="this.className='Btn BtnHv'" onMouseOut="this.className='Btn BtnNml'" type="submit" value="增加主机">
      <input name="__H" value="add" type="hidden" />
      </td>
      <td></td>
      <td></td>
    </tr>
</table>
<script>
function checkdata() {
	if($('#network').attr('checked') == true && $('#network_url').val() == '') {
		//showMsg('您选择了网络存储方式，网络存储URL不能为空！');
		parent.myshow('您选择了网络存储方式，网络存储URL不能为空！');
		return false;	
	}
	if($('#title').val() == '' || $('#host_name').val() == '') {
		parent.myshow('主机域名、主机名称是必填项！');
		//showMsg();
		return false;	
	}
}
</script>
<h4 id="oH4Check" class="Ibx_Lst_bExtra">多个主机随机选择</h4>
<style type="text/css">
.host_list{}
.host_list tr{border-bottom:1px solid #CCC;}
.host_list tr td{font-size:12px;}
</style>
<table class="host_list" id="host_list" cellpadding="1" cellspacing="5" style="border-spacing:5px; border-collapse:separate; border-bottom:solid 1px #CCC;">
    <tr id="title">
        <td width="29"></td>
        <td>主机名称</td>
        <td>主机域名</td>
        <td>外网ip</td>
        <td>局域网ip</td>
        <td>主机类型</td>
        <td>是否激活</td>
        <td>存储方式</td>
        <td>本地储存路径</td>
        <td>ftp端口</td>
        <td>ftp用户名</td>
        <td>ftp密码</td>
        <td>网络存储URL</td>
        <td>添加时间</td>
        <td>修改</td>
     </tr>        
<?php 
if(!empty($hosts)) {
	$arrHostsKV['read_host'] = '文件';
	$arrHostsKV['pic_host'] = '图片';
	$arrHostsKV['html_host'] = 'html';
	$arrHostsKV['ftp'] = 'ftp';
	$arrHostsKV['local'] = '本地';
	$arrHostsKV['network'] = '网络';
	$arrHostsKV['1'] = '激活';
	$arrHostsKV['0'] = '不激活';
	foreach($hosts as $k => $v) {
echo '<tr><td title="hid" type="hidden" text="">'.$v['hid'].'</td>
    <td title="title" type="text" text="主机名称">'.$v['title'].'</td>
    <td title="host_name" type="text" text="主机域名">'.$v['host_name'].'</td>
    <td title="web_ip" type="text" text="外网ip">'.$v['web_ip'].'</td>
    <td title="local_ip" type="text" text="局域网ip">'.$v['local_ip'].'</td>
	<td title="types" type="radio" text="主机类型">'.$arrHostsKV[$v['types']].'</td>
    <td title="is_use" type="radio" text="是否激活">'.$arrHostsKV[$v['is_use']].'</td>
    <td title="storage_type" type="radio" text="存储方式">'.$arrHostsKV[$v['storage_type']].'</td>
	<td title="local_path" type="text" text="本地存储路径">'.$v['local_path'].'</td>
	<td title="ftp_user" type="text" text="ftp用户名">'.$v['ftp_user'].'</td>
    <td title="ftp_passwd" type="text" text="ftp密码">'.$v['ftp_passwd'].'</td>
    <td title="ftp_port" type="text" text="ftp端口">'.$v['ftp_port'].'</td>
    <td title="network_url" type="text" text="网络存储URL">'.$v['network_url'].'</td>
    <td text="">'.$v['add_date'].'</td>
	<th><a href="javascript:" onclick="getThishtml(this)">修改</a></th></tr>';
	}
}
?>
</table>
<script>
function getThishtml(obj) {
	obj = $(obj).parent().parent().find('td');
	var html = '';
	var i = 0;
	var input ='';
	$(obj).each(function(index, element) {
		var storage_type1 = storage_type2 = storage_type3 = types1 = types2 = is_use1 = is_use2 = dot = '';
		if(obj.eq(index).attr('title') != '') {
			if(obj.eq(index).attr('type') == 'text' || obj.eq(index).attr('type') == 'hidden') {
				input = '<input class="Ipt" type="' 
					 +  obj.eq(index).attr('type') + '" value="' + obj.eq(index).html() 
					 + '" name="' + obj.eq(index).attr('title') +'" />';
			} else {
				if(obj.eq(index).attr('title') == 'types') {
					types1 = types2 = types3 ='';
					if(obj.eq(index).html() == '文件') {types1 = 'checked="checked"';} 
					if(obj.eq(index).html() == '图片') {types2 = 'checked="checked"';}
					if(obj.eq(index).html() == 'html') {types3 = 'checked="checked"';}
					input = '<input class="Ipt" type="radio" value="read_host" '+types1+' name="types" />文件'
						  + '<input class="Ipt" type="radio" value="pic_host" '+types2+' name="types" />图片'
						  + '<input class="Ipt" type="radio" value="html_host" '+types3+' name="types" />html';
				}
				if(obj.eq(index).attr('title') == 'is_use') {
					is_use1 = is_use2 = '';
					if(obj.eq(index).html() == '激活') {is_use1 = 'checked="checked"';} else {is_use2 = 'checked="checked"';};
					input = '<input class="Ipt" type="radio" value="1" '+is_use1+' name="is_use" />激活'
						  + '<input class="Ipt" type="radio" value="0" '+is_use2+' name="is_use" />不激活';
				}
				if(obj.eq(index).attr('title') == 'storage_type') {
					storage_type1 = storage_type2 = storage_type3 = '';
					if(obj.eq(index).html() == 'ftp') {storage_type1 = 'checked="checked"';}
					if(obj.eq(index).html() == '本地') {storage_type2 = 'checked="checked"';}
					if(obj.eq(index).html() == '网络') {storage_type3 = 'checked="checked"';}
					input = '<input class="Ipt" type="radio" value="ftp" '+storage_type1+' name="storage_type" />ftp'
					      + '<input class="Ipt" type="radio" value="local" '+storage_type2+' name="storage_type" />本地'
						  + '<input class="Ipt" type="radio" value="network" '+storage_type3+' name="storage_type" />网络';
				}
			}
			if(obj.eq(index).attr('type') != 'hidden' ) dot = ':';
			html += '<tr><td style="font-size:12px;">' + obj.eq(index).attr('text') + dot + '</td><td>'+input+'</td></tr>';
		}
    });
	html = '<table>'
	     + html + '</table>';
	myshow(html, '编辑文件主机');
	setTop('dvSysMsg', 20);
	closeDiv('btnSysReload');
	showDiv('btnSysOk');
	showDiv('btnSysCancel');
}
function ajaxPost(id) {
	obj = $("#"+id).find('input');
	var post = name = value = '';
	$(obj).each(function(index, element) {
		name = obj.eq(index).attr('name');
		value = obj.eq(index).attr('value');
		if(obj.eq(index).attr('type') == 'radio' && obj.eq(index).attr('checked') != true) {
		} else {
			post +=  name + '=' + value + '&';
		}
	});//manager/hosts
	post += '__H=update';
	myshow('', '编辑文件主机');
	showDiv('load');
	$.post("<?php echo $this->config->base_url('manager/hosts') ?>", post,
		function(data){
			closeDiv('load');
			closeDiv('btnSysOk');
			closeDiv('btnSysCancel');
			showDiv('btnSysReload');
			myshow(data.message, '编辑文件主机'); // John
	}, "json");
}
</script>
<?php include 'inc/#edit_div.php';?>
